<?php 
$user = @$_SERVER['PHP_AUTH_USER'];
$pwd  = @$_SERVER['PHP_AUTH_PW'];

if(!$user || !$pwd){
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: Basic realm="Basic Authentication Sample');
    echo "请输入";exit;
}

print_r($_SERVER);